/*
 * @Description  : 封装请求
 * @Author       : YiDing Xue
 * @Date         : 2023-01-12
 * @LastEditors  : YiDing Xue
 * @LastEditTime : 2023-02-13
 */
import axios from 'axios'
import { resReject, resResolve, reqReject, reqResolve } from './interceptors'

export function createAxios(options = {}) {
  const defaultOptions = {
    timeout: 12000
  }
  const service = axios.create({
    ...defaultOptions,
    ...options
  })
  service.interceptors.request.use(reqResolve, reqReject)
  service.interceptors.response.use(resResolve, resReject)
  return service
}

export const request = createAxios({
  // baseURL: 'http://192.168.1.126:8000/api'
  baseURL: import.meta.env.VITE_BASE_URL
})
